package com.spark.market.service.impl;

import com.spark.market.api.dto.ItemInfo;
import com.spark.market.api.result.ItemListResult;
import com.spark.market.common.utils.AssertUtils;
import com.spark.market.service.ItemQueryCoreService;
import com.spark.market.service.manager.ItemManager;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ItemQueryCoreServiceImpl implements ItemQueryCoreService {
    @Resource
    private ItemManager itemManager;

    @Override
    public ItemListResult ListItem() {
        List<ItemInfo> itemInfoList = itemManager.selectAllItem();
        ItemListResult itemListResult = new ItemListResult();
        itemListResult.setListItem(itemInfoList);
        return itemListResult;
    }

    @Override
    public ItemInfo getItemDetail(Integer id) {
        AssertUtils.isNotNull(id, "id is null");
        return itemManager.selectItemById(id);
    }
}
